package com.just.login.scanner;

import com.just.login.annotations.component;

import java.util.Optional;

public class DaoScanner {

    public Object getComponent(String classpath) {
        Class<?> clazz = null;
        try {
            clazz = Class.forName(classpath);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        System.out.println(clazz);
        Object o = null;
        if (clazz.isAnnotationPresent(component.class)) {
            System.out.println("有@component注解的类是："+clazz.getName());
            try {
                o = clazz.newInstance();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        return o;
    }
}
